package com.example.baozidemo.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.example.baozidemo.entity.SysSystemEntity;
import com.example.baozidemo.service.SysSystemService;
import com.example.baozidemo.utils.R;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.Map;


/**
 * 系统用户
 *
 * @author chenshun
 * @email sunlightcs@gmail.com
 * @date 2021-04-07 16:26:27
 */
@RestController
@RequestMapping("generator/syssystem")
public class SysSystemController {
    @Autowired
    private SysSystemService sysSystemService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("generator:syssystem:list")
    public R list(@RequestParam Map<String, Object> params){
        IPage page = sysSystemService.queryPage(params,true);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    @RequiresPermissions("generator:syssystem:info")
    public R info(@PathVariable("id") Long id){
		SysSystemEntity sysSystem = sysSystemService.getById(id);

        return R.ok().put("sysSystem", sysSystem);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("generator:syssystem:save")
    public R save(@RequestBody SysSystemEntity sysSystem){
		sysSystemService.save(sysSystem);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("generator:syssystem:update")
    public R update(@RequestBody SysSystemEntity sysSystem){
		sysSystemService.updateById(sysSystem);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("generator:syssystem:delete")
    public R delete(@RequestBody Long[] ids){
		sysSystemService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
